/**
 * Created by Administrator on 2017/9/20.
 */

angular.module('dicicious-app', [
    'ui.router',
    'ngFileUpload',
    'ngAnimate',
    'ng.comfirm',
    'module.auth',
    'service.auth',
    'module.template',
    'module.homepage',
])

    .run(
    ['$rootScope', '$state','$http', '$stateParams',function ($rootScope, $state, $http,$stateParams) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
        //$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState) {
        //    if(toState.name == "login" && fromState.name == "homepage" && AuthService.isAuthenticated()){
        //        event.preventDefault();
        //    }
        //    if(toState.name == "main" && fromState.name == "login"){
        //        event.preventDefault();
        //        $state.go("login");
        //    }
        //});


    }]
)
    .config(
    ['$stateProvider', '$urlRouterProvider', '$locationProvider', '$httpProvider',
        function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) {
            $urlRouterProvider.otherwise('/home');
            $httpProvider.defaults.withCredentials = true;
        }
    ]
);